package com.example.jsf.controller;

import com.example.jsf.Repository.TestRepository;
import com.example.jsf.entity.Income;
import com.example.jsf.other.DataHelper;
import com.example.jsf.other.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class Test {

    @Autowired
    private TestRepository testRepository;
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @RequestMapping("hello")
    public void hello(){
        System.out.println("hello");
    }

    @GetMapping("testList")
    public Result testList(String goodsName) {
//        System.out.print(testRepository.getIncomeList());
//        return Result.success(testRepository.getIncomeList());
        String s = DataHelper.selectSQL(Income.class);
        s+="where goods_name = '"+ goodsName+"' ";
        System.out.println("s = " + s);
        return Result.success(DataHelper.pageQuery(jdbcTemplate,s,1,10,Income.class));
    }


}
